unit RelatorioClassificacaoFinanceiraCentroCusto;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormRelatorio, DB, DBTables, StdCtrls, QRCtrls, QuickRpt,
  ExtCtrls;

type
  TFRelatorioClasificacaoFinanceiraCentroCusto = class(TFormRelatorio)
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRBand2: TQRBand;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    Query1: TQuery;
    QRExpr2: TQRExpr;
    QRExpr3: TQRExpr;
    QREPlano: TQRExpr;
    QRExpr1: TQRExpr;
    Query1CODIGOPLANOCENTRO: TIntegerField;
    Query1ESTRUTURA: TStringField;
    Query1PLANO: TStringField;
    Query1CENTRO: TStringField;
    Query1CONTACREDITO: TStringField;
    Query1CONTADEBITO: TStringField;
    Query1CODIGOCREDITO: TStringField;
    Query1CODIGODEBITO: TStringField;
    procedure QRBand2BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure QRLabel3Print(sender: TObject; var Value: String);
  private
    Function alinhamento(s : string) : integer;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FRelatorioClasificacaoFinanceiraCentroCusto: TFRelatorioClasificacaoFinanceiraCentroCusto;

implementation

uses UDmFinanceiro, UGeral;


{$R *.dfm}

Function TFRelatorioClasificacaoFinanceiraCentroCusto.alinhamento(s : string) : integer;
var i : integer;
begin
 result:=0;
 i:=0;
 for i := 0 to Length(s) - 1 do
  if s[i] = '.' then
   inc(result);
end;


procedure TFRelatorioClasificacaoFinanceiraCentroCusto.QRBand2BeforePrint(
  Sender: TQRCustomBand; var PrintBand: Boolean);
var plano : string;
begin
  inherited;
 if (Query1.FieldByName('CODIGOPLANOCENTRO').AsVariant = null) then // No Pai
  begin
   QRBand2.Height:=20;
   QRExpr2.Width:=0;
   QRExpr3.Width:=0;
   QREPlano.Font.Style:=[fsBold];
   QREPlano.Left:=2;
  end
 else
  begin
   //QRBand2.Height:=43;
   QRBand2.Height:=45;
   QREPlano.Font.Style:=[];
   QREPlano.Top:=2;
   QREPlano.Left:=alinhamento(Query1.FieldByName('ESTRUTURA').AsString)+3;
   QRExpr1.Left:=QREPlano.Left;
   QRExpr1.Top:=19;
   //163
   QRExpr3.Width:=368;
   QRExpr3.Top:=QREPlano.Top;
   QRExpr2.Width:=368;
   QRExpr2.Top:=QRExpr1.Top;
  end;
 QREPlano.Width:=354;

 {if not Query1.Bof then
  begin
   Query1.Prior;
   plano:=Query1.FieldByName('PLANO').AsVariant;
   Query1.Next;
  end;

 if not(Query1.Eof) then
  if Query1.FieldByName('PLANO').AsVariant = plano then
   QREPlano.Width:=0;
{  else
   QREPlano.Width:=193;}

end;

procedure TFRelatorioClasificacaoFinanceiraCentroCusto.FormCreate(
  Sender: TObject);
begin
  inherited;
 QRelatorio.Close;
 QRelatorio.SQL.Clear;
 QRelatorio.SQL.Add('Select Emp_Razao as Razao from empresa ');
 QRelatorio.SQL.Add('Where Emp_Codigo = :Cod ');
 QRelatorio.ParamByName('Cod').AsInteger:=Codigoempresa;
 QRelatorio.Open;
 QRLNomeEmpresa.Caption:=QRelatorio.fieldByname('Razao').AsString;

end;

procedure TFRelatorioClasificacaoFinanceiraCentroCusto.QRLabel3Print(
  sender: TObject; var Value: String);
begin
  inherited;
value:='';
end;

end.
